package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AppLogininfo;
import com.ruoyi.system.service.IAppLogininfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * app登录记录Controller
 * 
 * @author zw
 * @date 2022-03-28
 */
@RestController
@RequestMapping("/system/applogininfo")
public class AppLogininfoController extends BaseController
{
    @Autowired
    private IAppLogininfoService appLogininfoService;

    /**
     * 查询app登录记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:applogininfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppLogininfo appLogininfo)
    {
        startPage();
        List<AppLogininfo> list = appLogininfoService.selectAppLogininfoList(appLogininfo);
        return getDataTable(list);
    }

    /**
     * 导出app登录记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:applogininfo:export')")
    @Log(title = "app登录记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppLogininfo appLogininfo)
    {
        List<AppLogininfo> list = appLogininfoService.selectAppLogininfoList(appLogininfo);
        ExcelUtil<AppLogininfo> util = new ExcelUtil<AppLogininfo>(AppLogininfo.class);
        return util.exportExcel(list, "applogininfo");
    }

    /**
     * 获取app登录记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:applogininfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appLogininfoService.selectAppLogininfoById(id));
    }

    /**
     * 新增app登录记录
     */
    @PreAuthorize("@ss.hasPermi('system:applogininfo:add')")
    @Log(title = "app登录记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppLogininfo appLogininfo)
    {
        return toAjax(appLogininfoService.insertAppLogininfo(appLogininfo));
    }

    /**
     * 修改app登录记录
     */
    @PreAuthorize("@ss.hasPermi('system:applogininfo:edit')")
    @Log(title = "app登录记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppLogininfo appLogininfo)
    {
        return toAjax(appLogininfoService.updateAppLogininfo(appLogininfo));
    }

    /**
     * 删除app登录记录
     */
    @PreAuthorize("@ss.hasPermi('system:applogininfo:remove')")
    @Log(title = "app登录记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appLogininfoService.deleteAppLogininfoByIds(ids));
    }
}
